
<%@ page import="pc.system.*,wstrader.*,wstrader.task.*" %>

<%
    Users user = Trader.getUser(request.getParameter("uid"));
	
	if (user == null || !user.Authenticated()) {
		response.sendRedirect("logon.jsp");	
		return;
	}
	wstrader.task.trade.Allocation ftask = user.trade.allocation;
	wstrader.task.trade.allocation.Contract task = user.trade.allocation.contract;
	((Tasks)ftask.getOwner()).clearFocus();
	ftask.setFocus(true);
	Trader.window_width = "75%";
	
%>
	

<%
	long focused_id = task.doTask();
	if (focused_id <= 0) focused_id = 1;

	String view = request.getParameter("view");
	String contracts = request.getParameter("contracts");

	if (view==null) view ="0";
	if (contracts==null) contracts ="0";
	ResultSet rs;
%>

<%@include file="../header.jsp"%>

<link href="style.css" rel="stylesheet" type="text/css">

<style type="text/css">
<!--
.style3 {font-weight: bold}
-->
</style>

<form method="POST" name="formMain" action="" onSubmit="">				  
<table width="100%" border="0" class="style2">
	<tr>
	  <td valign="middle">	    	    <img src="images/allocation.jpg" width="250" height="30"> </td>
	</tr>
	<tr><td height="468" valign="top">
    <table width="100%" height="466" border="1" cellpadding="0" cellspacing="0" class="style2">
      <tr valign="top">
	  <td width="200" height="464"><table width="100%">
	  	<tr><td align="center" bgcolor="#EEEEEE" class="style1">Contracts</td>
	  	</tr>
	  	<tr><td height="412" valign="top">
	  		<select name="contracts" size="27" class="style2" id="contracts" style="width:112px; border:0" onChange="doListClick()">
				<%
					task.getResponse().setOption(task.getConditionalList("ref_number","type","S","contracts"));
					task.getResponse().setSelected("contracts",focused_id);
				%>
     		</select>
	  	</td></tr>
		<tr><td height="23" align="left" valign="bottom">&nbsp;</td>
		</tr>
	  </table></td>
        <td width="100%" align="top" ><table width="100%"><tr><td>
<table width="100%" height="309" border="0" class="style2">
        

        <tr align="top" style="height:260px">
          <td width="80%" height="29" colspan="11" valign="top" class="style2" align="center"><div align="center" id=scroll1 style="BORDER:0px ; OVERFLOW: auto; WIDTH: 80%; HEIGHT: 260px;">
            <div align="justify">
              <table width="100%"  border="1" cellspacing="1" cellpadding="1">
                <tr align="center" bgcolor="#EEEEEE" class="style3">
                  <td width="7%" class="style2">Id</td>
                    <td width="15%" class="style2">Cnt.Ref.No</td>
                    <td width="15%" class="style2">Tons</td>
                    <td width="13%" class="style2">Quality</td>
                    <td width="18%" class="style2">Grade</td>
                    <td width="18%" class="style2">Ls.Ship. Date</td>
                    <td width="11%" class="style2">Delv.Qty</td>
                    <td width="12%" class="style2">Tons To Alc.</td>
                  </tr>
                <%
				ResultSet Rs = task.fetchPurCntUnAlcList();
				int dLoop=1;
				Rs.beforeFirst();
					while (Rs.next())
					{			
			%>
                <tr id=<%=Rs.getInt("id")%> onClick="selectRow(this);" onDblClick="dbClick(this);">
                  <td align="left" class="style2">&nbsp;<%=Rs.getInt("id")%></td>
              			    <td align="left" class="style2">&nbsp;<%=Rs.getString("ref_number")%></td>
              			    <td align="right" class="style2"><%=Utils.numberToStr(Rs.getFloat("tons"),3)%>&nbsp;</td>
              			    <td align="right" class="style2"><%=task.getFieldValueForId("quality_master","name",Rs.getInt("grade_id"))%>&nbsp;</td>
              			    <td align="right" class="style2"><%=task.getFieldValueForId("grade_master","name",Rs.getInt("grade_id"))%>&nbsp;</td>
              			    <td align="right" class="style2"><%=Utils.dateToStr(Rs.getDate("last_date"))%>&nbsp;</td>
              			    <td align="right" class="style2"><%=Utils.numberToStr(Rs.getFloat("receive_tons"),2)%>&nbsp;</td>
              			    <td align="right" class="style2"><%//=Utils.numberToStr(Rs.getFloat("price_foreign"),2)%>&nbsp;</td>
            			    </tr>
                <%
			
						dLoop=dLoop+1;
					}
				if (dLoop==1)
				{
			
			%>
                <tr>
                  <td align="left">&nbsp;</td>
              			    <td align="left">&nbsp;</td>
              			    <td align="right">&nbsp;</td>
              			    <td align="right">&nbsp;</td>
              			    <td align="right">&nbsp;</td>
              			    <td align="right">&nbsp;</td>
              			    <td align="right">&nbsp;</td>
						    <td align="right">&nbsp;</td>
            		    </tr>
                <%
			
				}
			
			%>			              <tr>
                  <td colspan="8" align="left"><img src="images/new.gif" width="15" height="15" onclick="doAddNew()" />&nbsp;<img src="images/delete.gif" width="15" height="15" onclick="doDelete()" /></td>
                  </tr>
              </table>
            </div>
          </div>            </td>
		  </tr>
</table>
</td></tr>
<tr>
	<td class="style3">&nbsp;</td>
</tr>
<tr>
<td align="right">&nbsp;</td>
</tr>
</table>
		
		</td>
      </tr>
  </table>
</td></tr>
    <tr>
      <td>&nbsp;</td>
    </tr>
    <tr><td align="right">&nbsp;&nbsp;&nbsp;</td>
    </tr>
</table>  
	<span class="style3"><input type="hidden" name="uid"        id="uid"       value="<%=user.getuid()%>">		
    <input type="hidden" name="task_id"    id = "task_id"   value="0">
  </span>
</form>

<div align="left"><span class="style3">
  <%
	//rc.close();
%>
  <%@include file="../footer.jsp"%>
  
  </span>
  
</div>
